﻿@using System.Globalization
@model Griffin.MvcContrib.Areas.Griffin.Models.LocalizeTypes.IndexModel
@{
    ViewBag.Title = "Index";
}
<div class="griffin">
    @Html.Partial("_menu")
    <h2>@CultureInfo.CurrentUICulture.DisplayName</h2>
    @using (Html.BeginForm("CreateLanguage", "LocalizeViews"))
    {
        @Html.ValidationSummary(true)
        <div style="float: right">
            Change language:
            @Html.DropDownList("changeLanguage", Model.CultureItems, "", CultureInfo.CurrentUICulture.Name)
            <div style="background-color: aliceblue; margin-top: 10px;">
                Create language (should be a lang code like "sv-se")
                <br />
                <input type="text" name="lang" />
                <input type="submit" value="Create" />
            </div>
        </div>
    }
    @using (Html.BeginForm("Index"))
    {
        <div style="float: left">
            Namespace: @Html.TextBoxFor(model => model.TableFilter)
            <br />
            Show only untranslated @Html.CheckBoxFor(model => Model.OnlyNotTranslated)
        </div>
        <input type="submit" value="show" />
        <div style="clear: both"></div>
    }
    <table>
        <tr>
            <th>
                Typename
            </th>
            <th>
                TextName
            </th>
            <th>
                TranslatedText
            </th>
            <th>
            </th>
        </tr>
        @foreach (var item in Model.Prompts)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.ModelName)
                    <span style="color: #cccccc">@Html.DisplayFor(modelItem => item.Namespace)</span>
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TextName)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.TranslatedText)
                </td>
                <td style="width: 64px">
                    <a href="@Url.Action("Edit", new { id = item.TextKey })" title="Edit text" style="text-decoration: none">
                        <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/edit.png")"/>
                    </a><a href="@Url.Action("Delete", new { id = item.TextKey })" title="Delete text" style="text-decoration: none">
                        <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/delete.png")"/>
                    </a>
                    @if (item.Namespace != "CommonPrompts")
                    {
                        <a href="@Url.Action("MakeCommon", new { id = item.TextKey })" title="Share text between views" style="text-decoration: none">
                            <img src="@Url.Content("~/Areas/Griffin/Content/GriffinImg/generic.png")"/>
                        </a>
                    }
                </td>
            </tr>
        }
    </table>
    <script type="text/javascript">

        $(function() {
            $('#ShowMetadata').click(function() {
                var show = this.checked ? 1 : 0;
                setCookie('ShowMetadata', show, 365);
                window.location.reload();
            });
            $('#changeLanguage').change(function() {
                window.location = '@Url.Action("Index")?lang=' + $('#changeLanguage').val();
            });

        });

    </script>
</div>
